package ${packageName}.item;

import android.databinding.ObservableField;
import android.graphics.drawable.Drawable;
import android.support.annotation.NonNull;
import android.support.v4.content.ContextCompat;

import ${applicationPackage}.R;
import ${packageName}.viewModel.${viewModelName};

import me.goldze.mvvmhabit.base.ItemViewModel;
import me.goldze.mvvmhabit.binding.command.BindingAction;
import me.goldze.mvvmhabit.binding.command.BindingCommand;

public class ${itemViewModelName}  extends ItemViewModel<${viewModelName}> {
    public ObservableField<String> entity = new ObservableField<>();
    public Drawable drawableImg;

    public ${itemViewModelName}(@NonNull ${viewModelName} viewModel, String entity) {
        super(viewModel);
        this.entity.set(entity);
        //ImageView的占位图片，可以解决RecyclerView中图片错误问题
        drawableImg = ContextCompat.getDrawable(viewModel.getApplication(), R.mipmap.ic_launcher);
    }

    //条目的点击事件
    public BindingCommand itemClick = new BindingCommand(new BindingAction() {
        @Override
        public void call() {
            viewModel.clickItemLiveData.setValue(${itemViewModelName}.this);
        }
    });
    //条目的长按事件
    public BindingCommand itemLongClick = new BindingCommand(new BindingAction() {
        @Override
        public void call() {

        }
    });
}
